//
//  Favoris.m
//  Truffle
//
//  Created by Ismaila Kredity on 07/02/10.
//  Copyright 2010 kredity. All rights reserved.
//

#import "Favoris.h"

int type = 0; //0 pour les passerelles et 1 pour les contacts

@implementation Favoris

/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	

	self.title = @"Favoris";
	list = [[NSArray alloc] init];
	listContacts = [[NSArray alloc] initWithObjects:@"Iso", @"Afkir", @"Jon", nil];
	listPasserelles = [[NSArray alloc] initWithObjects:@"Pass_01.lip6", @"Pass_02.lip6", nil];
	list = listPasserelles;
}


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/


- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
	
	[tableView reloadData];
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tblView {
	return 1;
}


- (NSInteger)tableView:(UITableView *)tblView numberOfRowsInSection:(NSInteger)section {
	return [list count];
}

- (UITableViewCell *)tableView:(UITableView *)tblView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
	static NSString *CellIdentifier = @"Cell";

	UITableViewCell *cell = [tblView dequeueReusableCellWithIdentifier:CellIdentifier];
	if (cell == nil) {
		cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
		cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; 
	}
	NSString * libelle =[list objectAtIndex:indexPath.row];
	
	cell.textLabel.text = libelle;
	
	return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
	
	/*libAffectationSelected = [listCategories objectAtIndex:indexPath.row];
	NSDecimalNumber * id_aff = [listIDCategories objectAtIndex:indexPath.row];
	
	self.idAffectationSelected = id_aff;
	[id_aff release];*/
	//Dismiss the controller.
	[self.navigationController dismissModalViewControllerAnimated:YES];
}

//Get Passerelles
- (IBAction) GetPasserelles:(id)sender {
	type = 0;
	//Dismiss the controller.
	//[self.navigationController dismissModalViewControllerAnimated:YES];
	list = listPasserelles;
	[tableView reloadData];
}

//Get contacts
- (IBAction) GetContacts:(id)sender {
	//Dismiss the controller.
	//[self.navigationController dismissModalViewControllerAnimated:YES];
	type = 1;
	list = listContacts;
	[tableView reloadData];
}	


// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
}



- (void)dealloc {
    [super dealloc];
}


@end
